Release 10.1A: OpenEdge Reporting:
Query/Results Administration and Development
Accessing and editing the current query
The following sections provide information about how to use the API shared variables and procedures to access and edit information associated with the current query in Results.
Determining the current view
Use the
qbf–moduleshared variable in your feature and integration procedures to determine and set the current view for the current query in Results. Theqbf–modulecharacter variable holds one of the characters listed in Table 3–8.
Table 3–8: View character codes Value Current view? No current query or viewb Browse viewf Form viewr Report viewl Label viewe Data Export view
When the
qbf–modulevariable contains the unknown value (?), there is no current query or view in the Results application window.When you set the
qbf–modulevariable in a feature procedure, make sure the output parameter controlling the redisplay of Results is set toTRUE. Consider the following feature procedure example that is presented in Example 3–4.
The last line of this feature procedure sets the
winState outputparameter toTRUE. This causes the Results window to redraw and display the changed module state when the feature procedure finishes executing.Determining the name of the current query
The shared variable
qbf-namecontains the name of the current query in Results. If you set theqbf-namevariable in a feature procedure to a query that does not exist in the current query directory, Results creates a new temporary query definition. To save the new query definition permanently in the current query directory, execute the FileSave feature from a feature procedure or choose QuerySave while the query is active in Results.
Accessing the tables and selection criteria of the current query
Results provides API procedures that retrieve information about the tables in the current query.
The
vgtbll.pAPI procedure retrieves a list of the tables referenced in the current query. Use the following syntax to call thevgtbll.pAPI procedure from a feature procedure:
The
OUTPUTtableList parameter is a string value containing a comma-separated list of table or alias names referenced in the currently active query.The
vgtbli.pAPI procedure retrieves information about the join and selection criteria for a specified table referenced in the current query.Use the following syntax to call the
vgtbli.pAPI procedure from a feature procedure:
The following list describes the parameters of the
vgtbli.pAPI procedure:Parameters for the vgtbli.p API procedure
The following list describes the parameters of the
vgtbli.pAPI procedure:INPUTtableNameA string value representing the name of a table or alias used in the current query.
OUTPUTrefTableIf
tableNameis an alias, this parameter is a string value representing the name of the table associated with the alias. IftableNameis an actual table name, this parameter returns the unknown value (?).OUTPUTjoinTableA string value representing the name of a table to which the table specified with the first input parameter (
tableName) is joined.OUTPUTjoinInfoA string value containing the Progress 4GL statement relating the specified table with another table available in the currently active query.
OUTPUTwhereInfoA string value representing a selection expression in the
WHEREclause of the query. This string value does not contain the keywordWHEREand contains only the selection criteria defined explicitly for the query. If this output parameter yields an empty string, there is noWHEREcriteria for the corresponding table.OUTPUTwhereAskA string value representing the information used to prompt for a
WHEREclause value at run time. This is the syntax for the string:
The database field, the data type of the database field, the operator of the cirteria expression, and the prompt are listed.
OUTPUTincludeCodeA string value containing Progress 4GL statements to execute immediately after each record access from the specified table in the current query.
OUTPUTresultA logical value that indicates whether the API procedure executed successfully.
Determining the query sort order
Use the
qbf–sortbyvariable to retrieve and set the sorting information for the current query. Theqbf–sortbyvariable containsBYclauses but does not contain the keywordBY. The list in theqbf–sortbyvariable has the following form:
The fields are positioned in the list based on sort precedence, with the primary sort field listed first. The letters
DESCspecified after a field name in the list indicate that the sort order for the field is descending. If the field is an array field, the field name is followed by a number in square brackets (for example, [#], where # is the array element selected for ordering).Determining the fields in the current query
Results places information about the fields of the current query into several different API shared variables. Many of the API shared variables that store information about the fields of the current query are arrays. In each of these field information arrays, there is one element per field in the current query. Results places information about each field into the field information arrays based on the order in which the fields are added to the current query. You can use a single index value to access information about a particular query field across these arrays. For example, an index value of 3 used with each field information array yields information about the third field added to the current query.
These are the shared variables and arrays that contain information about the fields of the current query:
- qbf–rc# integer variable — Represents the total number of fields (database, calculated, and array elements) in the current query.
- qbf–rcn variable — Identifies a character array that contains names for each field in the current query. The contents of an element of this array vary depending on the information stored in the corresponding element of the
qbf–rccarray. If an element in theqbf–rccarray is blank, the corresponding element inqbf–rcnis a field name. Otherwise, the element contains a comma-separated list of information about a calculated field.The format of the information list of a calculated field varies depending on the type of calculated field. The name of the calculated field is always the first entry in the list. By default, the calculated field name is
qbf–###, where###is a three-digit number representing the index of the current element in theqbf–rcnarray. You can rename calculated fields using the Rename button in the Properties dialog box. TheENTRY(1,qbf–rcn[n])function always returns the field name from an element of theqbf–rcnvariable. Table 3–9 describes the format of the information list for each type of calculated field.- qbf–rcc variable — Identifies a character array that is used to store information for each calculated field and stacked array in the current query. (Stacked arrays display the elements in a column within a single field on the display.) If the first character is blank, the associated field is not a calculated field or a stacked array. For each calculated field in the
qbf–rccvariable, the corresponding element inqbf–rcncontains information about the expression used to calculate the field.Table 3–9 describes the symbols used in an element of the
qbf–rccarray to represent the different types of calculated fields.
Note: For calculated field typess,n,l, andd,ENTRY(1,qbf–rcn[n])is the column name andSUBSTRING(qbf–rcn,INDEX(qbf–rcn[n],",") + 1)contains the expression. You cannot useENTRY(2,...)to retrieve the expression, since it might have embedded commas.- The
qbf–rcgvariable is a character array containing totals information for each field in the current query. Elements that contain an empty string have no totals information for the corresponding query field. If an element contains an ampersand (&), repeating values are hidden for the associated field.An element of the
qbf–rcgvariable can also contain one or more aggregate strings that consist of a leading letter followed by an integer or 0. An aggregate string must have one of the forms listed in Table 3–10.
Table 3–10: Aggregate string Character Description tn Totalcn Count an Average nn Minimum xn MaximumIf
nis 0, the total accumulation for the associated field is placed on the bottom line (summary line) of the report view of the current query. Ifnis an integer, it identifies an element in theqbf–sortbyvariable containing the name of a query field that triggers the accumulation.An aggregate string can also contain a dollar sign ($), which indicates that the accumulate string is a totals-only string.
- The
qbf–rclvariable is a character array containing labels for each field in the current query. Stacked column labels are supported. In stacked column labels, an exclamation point (!) breaks column labels into more than one level.- The
qbf–rcfvariable is a character array containing format strings for each field in the current query. All OpenEdge Data Dictionary formats are supported.The
qbf–rcpvariable is a character array containing layout parameters related to the report, form, and label views for a field in the current query. Each element of theqbf–rcpvariable has the following syntax:
Table 3–11 are the entries contained in each element of the
qbf–rcpvariable:
Note: Do not set an element of theqbf–rcpvariable to the empty string. Instead, set the element to a character string containing five commas (“,,,,,”).- The
qbf–rcwvariable is an integer array containing character widths for each query field in the report view. The width of each field includes format, label widths, and stacked labels. This variable is for information purposes only. Results calculates the character width of a field automatically when the query displays.- The
qbf–rctvariable is an integer array containing a data type identifier for each field in the current query. The data type identifier is an integer value between 1 and 7 (inclusive) that maps to a list element contained in theqbf–dtypevariable.The
qbf–dtypecharacter variable containing a comma-separated list of data types. The default value of this variable is a character array:
Use this variable with the
qbf–rctvariable to determine the data type of a field in the current query.Determining the report format of the current query
The
vgrpti.pAPI procedure retrieves report format information associated with the current query. Use the following syntax to call thevgrpti.pAPI procedure from a feature procedure:
Parameters of the vgrpti.p API procedure
The following list describes the parameters of the
vgrpti.pAPI procedure:OUTPUTleftOriginAn integer representing left margin setting, in characters, from the output origin (page or display window).
OUTPUTtopOriginAn integer representing top margin setting, in characters, from the output origin (page or display window).
OUTPUTcolumnSpaceAn integer representing the number of character units between fields on the report.
OUTPUTlineSpaceAn integer representing the number of empty lines between text lines on the report.
OUTPUTpageLinesAn integer representing the maximum number of lines allowed on a printed page of the report.
OUTPUTheadSpaceAn integer representing the number of lines between the report body and the report header.
OUTPUTfootSpaceAn integer representing the number of lines between the report body and the report footer.
OUTPUTpageEjectA string value containing the name of the report field used for page ejects.
OUTPUTsumReportA logical value that specifies whether the report is a summary report.
The report view does not have to be active in Results in order to run the
vgrpti.pAPI procedure.Setting table information for the current query
The
vstbli.pAPI procedure sets table information associated with the current query. Use the following syntax to call thevstbli.pAPI procedure from a feature procedure:
Parameters of the vstbli.p API procedure
The following list describes the parameters of the
vstbli.pAPI procedure:INPUTtableNameA string value representing the name of a table or alias used in the current query. The table name must be fully qualified (for example, db.table.name).
INPUTjoinTableA string value representing the name of the table to which tableName is joined, if any.
INPUTjoinInfoA string value containing the Progress 4GL code defining the join relationship between joinTable and tableName.
INPUTwhereInfoA string value representing a selection expression in the
WHEREclause of the query. This string value does not contain the keywordWHEREand contains only the selection criteria defined explicitly for the query.INPUTwhereAskA string value representing the information used to prompt for a
WHEREclause value at run time. This is the syntax for the string value:
The field, the data type of the field, the operator of the criteria expression, and prompt string are listed.
INPUTincludedCodeA string value containing Progress 4GL statements to execute immediately after each record access from the specified table in the current query.
OUTPUTresultA logical value that indicates whether the API procedure executed successfully.
Setting the list of tables for the current query
The
vstbll.pAPI procedure sets the list of tables associated with the current query. Use the following syntax to call thevstbll.pAPI procedure from a feature procedure:
Parameters of the vstbll.p API procedure
The following list describes the parameters of the
vstbll.pAPI procedure:INPUTtableListA string value containing a list of tables to be used in the current query. The table names must be fully qualified (for example,
db.table.name).OUTPUTresultA logical value that indicates whether the API procedure executed successfully.
Setting the export format for the current query
The
vsexpi.pAPI procedure sets the export format for the current query. Use the following syntax to call thevsexpi.pAPI procedure from a feature procedure:
Parameters of th vsexpi.p API procedure
The following list describes the parameters of the
vsexpi.pAPI procedure:INPUTnewFormatA string value representing the name of the export format to make active for the current query. If the format name is not found in the list of existing formats, it is not set.
OUTPUTresultA logical value that indicates whether the API procedure executed successfully.
OUTPUToldFormatA string value representing the name of the old (prior to calling this API) export format. This information can be used to restore the export format to its original state at the end of the feature procedure.
Setting the report format for the current query
The
vsrpti.pAPI procedure sets the report (page) format for the current query. Use the following syntax to call thevsrpti.pAPI procedure from a feature procedure:
Parameters of the vsrpti.p API procedure
The following list describes the parameters of the
vsrpti.pAPI procedure:INPUTnewFormatA string value representing the name of the page format to make active for the current query. If the format name is not found in the list of existing formats, it is not set.
OUTPUTresultA logical value that signals whether or not the API procedure executed successfully.
OUTPUToldFormatA string value representing the name of the old (prior to calling this API) page format. This information can be used to restore the page format to its original state at the end of the feature procedure.
Setting the label format for the current query
The
vslbli.pAPI procedure sets the label format for the current query. Use the following syntax to call thevslbli.pAPI procedure from a feature procedure:
Parameters of the vslbli.p API procedure
The following list describes the parameters of the
vslbli.pAPI procedure:INPUTnewFormatA string value representing the name of the label format to make active for the current query. If the format name is not found in the list of existing formats, it is not set.
OUTPUTresultA logical value that indicates whether the API procedure executed successfully.
OUTPUToldFormatA string value representing the name of the old (prior to calling this API) label format. This information can be used to restore the label format to its original state at the end of the feature procedure.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |